//
//  StatusCell.swift
//  01-WeiBo
//
//  Created by 李晓东 on 17/7/7.
//  Copyright © 2017年 PeanutXu. All rights reserved.
//

import UIKit

/// 微博 Cell 中控件的间距数值
let StatusCellMargin: CGFloat = 12
/// 微博头像的宽度
let StatusCellIconWidth: CGFloat = 35

class StatusCell: UITableViewCell {

    var statusModel :StatusModel?{
        didSet{
            topView.viewModel = statusModel
            contentLabel.text = statusModel?.status.text
            
        }
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    lazy var topView : StatusTopCell = StatusTopCell()
    lazy var contentLabel :UILabel = UILabel(labelTxt: "微博正文", font: UIFont.systemFont(ofSize: 17), textColor:  UIColor.red,  screenInsert:StatusCellMargin)
//    lazy var contentLabel :UILabel = UILabel(labelTxt: "微博正文", font: UIFont.systemFont(ofSize: 17), textColor: UIColor.red, screenInsert:StatusCellMargin)
    
}

extension StatusCell{
    func setUI() {
        contentView.addSubview(topView)
        contentView.addSubview(contentLabel)
        
        topView.snp.makeConstraints { (make) in
            make.top.equalTo(contentView.snp.top)
            make.left.equalTo(contentView.snp.left)
            make.right.equalTo(contentView.snp.right)
            make.height.equalTo(2 * StatusCellMargin + StatusCellIconWidth)
//            make.bottom.equalTo(contentView.snp.bottom)
        }
        
        contentLabel.snp.makeConstraints { (make) in
            make.top.equalTo(topView.snp.bottom).offset(StatusCellMargin)
            make.left.equalTo(contentView.snp.left).offset(StatusCellMargin)
//            make.right.equalTo(contentView.snp.right).offset(-StatusCellMargin)
            make.bottom.equalTo(contentView.snp.bottom).offset(-StatusCellMargin)
        }
    
        print(contentView.frame.height,"%%%", contentView.snp.bottom)
    }
}
